import sql from "@/lib/sql";

// 保存交底书
export async function GET(request) {
  try {
    const name = request.nextUrl.searchParams.get('dynasty');
    const result = await sql.getDynastyDetail(name);

    if (result == undefined) {
      return Response.json({
        code: 201,
        status: "fail",
        msg: "获取朝代信息失败",
      });
    } else {
      return Response.json({
        code: 200,
        status: "success",
        msg: result,
      });
    }
  } catch (error) {
    return Response.json({
      code: 9000,
      status: "fail",
      msg: "请求格式错误：" + error + request,
    });
  }
}
